<template>
  <div>
    <query-pan @change="onQueryCondidateChange"></query-pan>
    <button-bar :is-mkt="isMkt" :page="page" @add-product="onAddProduct" @current-change="onCurrentChange"></button-bar>
    <table-pan ref="sptable" :is-mkt="isMkt" @page="onPageChange"></table-pan>
    <!-- <dlg-add ref="adduser"></dlg-add> -->
  </div>
</template>

<script>
import queryPan from "./index/c_query";
import buttonBar from "./index/c_bntbar";
import tablePan from "./index/c_table";
// import dlgAdd from './index/d_add';
// import dlgEdit from './index/d_edit';
export default {
  props: {
    isMkt: { type: Boolean, default: false } //是否超市商品
  },
  components: { queryPan, buttonBar, tablePan }, //{queryPan,buttonBar,tablePan,dlgAdd,dlgEdit} ,
  data() {
    return {
      page: {
        total: 0,
        size: 0,
        index: 0
      }
    };
  },
  created() {
    // let done=this.$route.query;
    // console.log(done);
  },
  methods: {
    //====查询面板的事件====================================================
    onQueryCondidateChange(qc) {
      qc.is_market = this.$props.isMkt; //添加商品类型条件
      this.$refs["sptable"].Query(qc);
    },
    //====按钮条的事件======================================================
    onAddProduct() {
      if (this.$props.isMkt) {
        const { href } = this.$router.resolve({
          name: "addproductmarket"
        });
        window.open(href, "_blank");
      } else {
        const { href } = this.$router.resolve({
          name: "addproduct"
        });
        window.open(href, "_blank");
      }
    },
    //-----------------------------------------------------------
    onCurrentChange(currentPage) {
      this.$refs["sptable"].onCurrentChange(currentPage);
    },
    onPageChange(page) {
      this.page = page;
    }
  }
};
</script>